class UtilsVo {
   // 字段下划线转化为驼峰
   static transformedResults(list = []) {
    return list.map((row) => {
        const transformedRow = {};
        Object.entries(row).forEach(([key, value]) => {
            const camelCaseKey = key.replace(/_([a-z])/g, (match, letter) => {
                return letter.toUpperCase();
            });
            transformedRow[camelCaseKey] = value;
        });
        return transformedRow;
    });
}

  // 字段下划线转化为驼峰 - 有数组转换
  static transformedResultsSpeKey(list = [], variable) {
    return list.map((row) => {
        const transformedRow = {};
        Object.entries(row).forEach(([key, value]) => {
            const camelCaseKey = key.replace(/_([a-z])/g, (match, letter) => {
                return letter.toUpperCase();
            });

            if(key === variable){
                // string 变为 array 
                const arrayValues = value.split(',')
                transformedRow[camelCaseKey] = arrayValues;
            }else{
                transformedRow[camelCaseKey] = value;
            }
        });
        return transformedRow;
    });
}

    static getType(variable) {
        return Object.prototype.toString.call(variable).slice(8, -1);
      }
}

module.exports = UtilsVo